extends Control

@onready var pause_menu: PanelContainer = $PanelContainer
@onready var camera_3d: Camera3D = $"../../Camera3D"
@onready var color_picker: ColorPicker = $PanelContainer/MarginContainer/VBoxContainer/ColorPicker
@onready var color_rect: ColorRect = $ColorRect

func _ready() -> void:
	Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
	color_rect.color = camera_3d.color


func _input(event: InputEvent) -> void:
	if event.is_action_pressed(&"pause"):
		set_pause()
		
		get_viewport().set_input_as_handled()


func set_pause() -> void:
	pause_menu.visible = not pause_menu.visible
	if pause_menu.visible:
		Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
		color_picker.color = camera_3d.color
	else:
		Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
		camera_3d.set_color(color_picker.color)
